apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ks-console
    tier: frontend
    version: {{ ks_version }}
  name: ks-console
  namespace: kubesphere-system
spec:
{% if master_num is defined and master_num != "0" %}
  replicas: {{ master_num }}
{% else %}
  replicas: 1
{% endif %}
  selector:
    matchLabels:
      app: ks-console
      tier: frontend
      version: {{ ks_version }}
  template:
    metadata:
      labels:
        app: ks-console
        tier: frontend
        version: {{ ks_version }}
    spec:
      imagePullSecrets:
      - name: qingcloud     
      containers:
      - image: {{ ks_console_repo }}:{{ ks_console_tag }}
        imagePullPolicy: {{ ks_image_pull_policy }}
        name: ks-console
        resources:
          limits:
            cpu: {{ ks_console_cpu_limit }}
            memory: {{ ks_console_memory_limit }}
          requests:
            cpu: {{ ks_console_cpu_requests }}
            memory: {{ ks_console_memory_requests }}
        volumeMounts:
        # - mountPath: /etc/kubernetes/pki
        #   name: ca-dir
        - mountPath: /root/KubeSphereUI/server/local_config.yaml
          name: ks-console-config
          subPath: local_config.yaml
        - mountPath: /root/KubeSphereUI/server/sample
          name: sample-bookinfo
      # - image: {{ redis_repo }}:{{ redis_tag }}
      #   imagePullPolicy: IfNotPresent
      #   name: redis
      serviceAccount: kubesphere
      serviceAccountName: kubesphere
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule
        - key: CriticalAddonsOnly
          operator: Exists
        - effect: NoExecute
          key: node.kubernetes.io/not-ready
          operator: Exists
          tolerationSeconds: 60
        - effect: NoExecute
          key: node.kubernetes.io/unreachable
          operator: Exists
          tolerationSeconds: 60
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            preference:
              matchExpressions:
              - key: node-role.kubernetes.io/master
                operator: In
                values:
                - ""
{% if master_num is defined and master_num != "1" %}
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - topologyKey: kubernetes.io/hostname
            labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - ks-console
            namespaces:
            - kubesphere-system
{% endif %}
      volumes:
      # - name: ca-dir
      #   secret:
      #     defaultMode: 420
      #     secretName: front-proxy-client
      - configMap:
          defaultMode: 420
          name: ks-console-config
          items:
          - key: local_config.yaml
            path: local_config.yaml
        name: ks-console-config
      - configMap:
          defaultMode: 420
          name: sample-bookinfo
        name: sample-bookinfo
        